local tianwei = fk.CreateSkill{
  name = "lingling__tianwei",
}

Fk:loadTranslationTable{
  ["lingling__tianwei"] = "天威",
  [":lingling__tianwei"] = "回合结束时，你可以将手牌数调整至与中央区花色数相同。",
}

tianwei:addEffect(fk.TurnEnd, {
  anim_type = "drawcard",
  can_trigger = function (self, event, target, player, data)
    if target == player and player:hasSkill(tianwei.name) then
      local suits = {}
      for _, id in ipairs(player.room:getBanner("@$CenterArea")) do
        table.insertIfNeed(suits, Fk:getCardById(id).suit)
      end
      table.removeOne(suits, Card.NoSuit)
      if player:getHandcardNum() ~= #suits then
        event:setCostData(self, {n = #suits})
        return true
      end
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local n = player:getHandcardNum() - event:getCostData(self).n
    if n > 0 then
      room:askToDiscard(player, {
        min_num = n,
        max_num = n,
        include_equip = false,
        skill_name = tianwei.name,
        cancelable = false,
      })
    else
      player:drawCards(-n, tianwei.name)
    end
  end,
})

tianwei:addAcquireEffect(function (self, player, is_start)
  player.room:addSkill("#CenterArea")
end)

return tianwei
